<%@page import="modele.FacadeSite, modele.Membre"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    
   <%
   InfoSession infoSession = (InfoSession)request.getAttribute("infoSession");
   HashMap<String,List<Competition>> menu = (HashMap<String,List<Competition>>) request.getAttribute("Menu");	
   HashMap<String,Long> idsSports = (HashMap<String,Long>) request.getAttribute("idsSports");	
   %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="modele.InfoSession, modele.Competition, java.util.List, java.util.LinkedList, java.util.HashMap, java.util.Set, java.util.Collection"%>

<html>
<head>
<link type="text/css" rel="stylesheet" href="css/main.css">
<script type="text/javascript" src="lib/wysiwyg/scripts/jquery.min.js"></script>
<script type="text/javascript" src="lib/jquery.idTabs.min.js"></script>
<script type="text/javascript" src="lib/wysiwyg/scripts/jquery.simpleEditor.js"></script>
<link rel="stylesheet" type="text/css" href="lib/wysiwyg/styles/jquery.simpleEditor.css">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<script type="text/javascript">
	$(document).ready(function(){
			$('li.menuDeroulant').hover(
				function() { $('ul', this).css('display', 'block'); },
				function() { $('ul', this).css('display', 'none'); });
			
			
			$('#statutMembreTmp').click(function () {
				$('#infosCompte').toggle();
			});
			
			
			// Plugin tab menu
			$("#usual1 ul").idTabs(); 
			
			$('#editor').simpleEditor.defaults = {
				toolBarPosition:'up',
				width: 800,
				height: 500,
				cssFile: 'lib/wysiwyg/styles/jquery.simpleEditorTemplate.css'
			};
			
			$('#editor').simpleEditor();

		});
</script>
<title>Sport Voice</title>
</head>
<body>			
	<div id="contener">
		
		<div id="header">
		
			<div id="banniere">
				<p>Sport Voice</p>
				<p id="slogan">à vous la parole</p>
			</div>
		
			<div id="compteTmp">
			<%
			// utilisateur inconnu ou non connecte 
			if(infoSession == null || infoSession.getConnecte() == false) {
				
			%>
				<div id="connexionCompteTmp">
					<p><a href="Compte?page=connexion">Connexion</a></p>
					<br />
					<p><a href="Compte?page=inscription">S'inscrire</a></p>
				</div>
			<%
			}
			else{
				Membre m = infoSession.getMembre();
				String statut="";
				
				if (m.isDroit_admin()) {
					statut = "administrateur";
				}
				else if (m.isDroit_rediger()) {
					statut = "redacteur";
				}
				else {
					statut = "membre";
				}
			%>
				<div id="statutMembreTmp">
					<h3>Mon compte</h3>
					<p><%=m.getPseudo() %></p>
				</div>
				<div id="infosCompte">
					<ul>
						<li>votre statut : <%=statut%>
						<li>Articles commentés : <%=m.getCommentaires().size() %></li>
						<li>Articles rédigés : <%=m.getArticles().size() %></li>
						<li>Commentaires appréciés : <%=m.getApprobationscommentaires().size() %></li>
						<li>Points actuels : <%=m.getPoints() %></li>
					</ul>
					<p><a href="Compte?page=modificationCompte">Modifier mon compte</a></p>
					<% if (m.isDroit_admin() || m.isDroit_rediger()) { %>
						<p><a href="Consultation?page=mesArticles&numeroPage=1&tri=date">Voir mes articles</a></p>
						<p><a href="Compte?page=redactionArticle">Rédiger un article</a></p>
					<%} %>
					<% if (m.isDroit_admin()) { %>
						<p><a href="Compte?page=creationCompetition">Créer une compétition</a></p>
						<%
					}
						if(m.getNbNotificationsNonVues()==1){%>
					<p><a href="Compte?page=mesNotifications&numeroPage=1">Vous avez 1 notification</a></p>
							<%}else{%>
					<p><a href="Compte?page=mesNotifications&numeroPage=1">Vous avez <%=m.getNbNotificationsNonVues()%> notifications</a></p>
						<%}%>
					<p><a href="Compte?page=deconnexion">Déconnexion</a></p>
				</div>
			<%
			}
			%>	
			</div>		
			<div id="headerRecherche">
				<form id="form_recherche" action="Recherche?numeroPage=1" method="POST">
					<p>Recherche par mots clés</p>
					<p><input type="text" id="texteRecherche" name="texteRecherche"/>
					<input type="submit" value="Rechercher"></p>
				</form>
			</div>
		</div>
		<div id="navigation">
			<ul>
				<li><a href="Site?page=accueil">Accueil</a></li>
				<%				
						String s = "Football";
						if (menu.get(s)==null){
							out.println("<li><a href=\"Consultation?page=articles&numeroPage=1&tri=date&sport="+s+"\">"+s+"</a></li>");
						}
						else{
							out.println("<li class=\"menuDeroulant\">");
							out.println("<a href=\"Consultation?page=articles&numeroPage=1&tri=date&sport="+idsSports.get(s)+"\">"+s+"</a>");
							out.println("<ul>");
							for (Competition c : menu.get(s)){
								out.println("<li><a href=\"Consultation?page=articles&numeroPage=1&tri=date&sport="+idsSports.get(s)+"&compet="+c.getId() +"\">" + c.getName() + "</a></li>");
							}
							out.println("</ul>");
							out.println("</li>");
						}
						
						s = "Rugby";
						if (menu.get(s)==null){
							out.println("<li><a href=\"Consultation?page=articles&numeroPage=1&tri=date&sport="+idsSports.get(s)+"\">"+s+"</a></li>");
						}
						else{
							out.println("<li class=\"menuDeroulant\">");
							out.println("<a href=\"Consultation?page=articles&numeroPage=1&tri=date&sport="+idsSports.get(s)+"\">"+s+"</a>");
							out.println("<ul>");
							for (Competition c : menu.get(s)){
								out.println("<li><a href=\"Consultation?page=articles&numeroPage=1&tri=date&sport="+idsSports.get(s)+"&compet="+c.getId()+"\">" + c.getName() + "</a></li>");
							}
							out.println("</ul>");
							out.println("</li>");
						}
						
						s = "Tennis";
						if (menu.get(s)==null){
							out.println("<li><a href=\"Consultation?page=articles&numeroPage=1&tri=date&sport="+idsSports.get(s)+"\">"+s+"</a></li>");
						}
						else{
							out.println("<li class=\"menuDeroulant\">");
							out.println("<a href=\"Consultation?page=articles&numeroPage=1&tri=date&sport="+idsSports.get(s)+"\">"+s+"</a>");
							out.println("<ul>");
							for (Competition c : menu.get(s)){
								out.println("<li><a href=\"Consultation?page=articles&numeroPage=1&tri=date&sport="+idsSports.get(s)+"&compet="+c.getId()+"\">" + c.getName() + "</a></li>");
							}
							out.println("</ul>");
							out.println("</li>");
						}
						
						s = "Basketball";
						if (menu.get(s)==null){
							out.println("<li><a href=\"Consultation?page=articles&numeroPage=1&tri=date&sport="+idsSports.get(s)+"\">"+s+"</a></li>");
						}
						else{
							out.println("<li class=\"menuDeroulant\">");
							out.println("<a href=\"Consultation?page=articles&numeroPage=1&tri=date&sport="+idsSports.get(s)+"\">"+s+"</a>");
							out.println("<ul>");
							for (Competition c : menu.get(s)){
								out.println("<li><a href=\"Consultation?page=articles&numeroPage=1&tri=date&sport="+idsSports.get(s)+"&compet="+c.getId()+"\">" + c.getName() + "</a></li>");
							}
							out.println("</ul>");
							out.println("</li>");
						}
					%>
					<li class="menuDeroulant">
						<a href="Consultation?page=rechercheCompetition">Plus</a>
						<ul>
						<li><a href="Consultation?page=articles&numeroPage=1&tri=date&sport=<% s="Formule 1"; out.println(idsSports.get(s)); %>">Formule 1</a></li>
						<li><a href="Consultation?page=articles&numeroPage=1&tri=date&sport=<% s="Golf"; out.println(idsSports.get(s)); %>">Golf</a></li>
						<li><a href="Consultation?page=articles&numeroPage=1&tri=date&sport=<% s="Cyclisme"; out.println(idsSports.get(s)); %>">Cyclisme</a></li>
						<li><a href="Consultation?page=rechercheCompetition">Autres</a></li>
						</ul>
					</li>	
			</ul>
		</div>
		 <div id="contenu">
			<%
			String pageInclue = (String)request.getAttribute("pageInclue");
			
			if(pageInclue == null){
				pageInclue = "accueil.jsp";
			}
			
			//out.println(pageInclue);
			%>
			<jsp:include page="<%= pageInclue%>"></jsp:include>
		</div>
		<div id="footer">
			&copy; 2011 site.com
		</div>
	</div> 
</body>
</html>